
function GM:PlayerSelectSpawn(pl)

	if (self.SpawnPoints1 == nil) then
	
		self.SpawnPoints1 = ents.FindByClass( "info_player_deathmatch" )
		//self.SpawnPoints1 = table.Add(self.SpawnPoints1, ents.FindByClass( "info_player_terrorist" ))
		self.SpawnPoints1 = table.Add(self.SpawnPoints1, ents.FindByClass( "info_player_rebel" ))
		//self.SpawnPoints1 = table.Add(self.SpawnPoints1, ents.FindByClass( "info_player_human" ))
		
	end
	if (self.SpawnPoints2 == nil) then
	
		self.SpawnPoints2 = ents.FindByClass( "info_player_start" )
		//self.SpawnPoints2 = table.Add(self.SpawnPoints1, ents.FindByClass( "info_player_counterterrorist" ))
		self.SpawnPoints2 = table.Add(self.SpawnPoints2, ents.FindByClass( "info_player_combine" ))
		//self.SpawnPoints2 = table.Add(self.SpawnPoints1, ents.FindByClass( "info_player_prop" ))

	end

	if pl:Team() == 1 then
		local Count = #self.SpawnPoints1
		if Count == 0 then return pl end
		for i=0, 20 do
			local ChosenSpawnPoint = self.SpawnPoints1[math.random(1, Count)]
			if ChosenSpawnPoint and ChosenSpawnPoint:IsValid() and ChosenSpawnPoint:IsInWorld() and ChosenSpawnPoint ~= LastUsedSpawnPoint then
				local blocked = false
				for _, ent in pairs(ents.FindInBox(ChosenSpawnPoint:GetPos() + Vector(-48, -48, 0), ChosenSpawnPoint:GetPos() + Vector(48, 48, 60))) do
					if ent and ent:IsPlayer() then
						blocked = true
					end
				end
				if not blocked then
					LastUsedSpawnPoint = ChosenSpawnPoint
					return ChosenSpawnPoint
				end
			end
		end
		return LastUsedSpawnPoint
	else
		local Count = #self.SpawnPoints2
		if Count == 0 then return pl end
		for i=0, 20 do
			local ChosenSpawnPoint = self.SpawnPoints2[math.random(1, Count)]
			if ChosenSpawnPoint and ChosenSpawnPoint:IsValid() and ChosenSpawnPoint:IsInWorld() then
			return ChosenSpawnPoint
			end
		end
	end
	return pl
end




